package com.mapreduce;

import com.bean.YearTemp;
import org.apache.hadoop.io.WritableComparator;

// 年份和温度相同的归为一个组
public class YearGroup extends WritableComparator {
    public YearGroup(){
        super(YearTemp.class,true);
    }
    @Override
    public int compare(Object a, Object b) {
        // YearTemp
        YearTemp yearTemp1 = (YearTemp) a;
        YearTemp yearTemp2 = (YearTemp) b;
        // 返回0就放在同一个组下面
        return yearTemp1.getYear().compareTo(
                yearTemp2.getYear());
    }
}
